
<script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function checkemail(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
        
        // Create a function that will receive data sent from the server
        ajaxRequest.onreadystatechange = function(){
            if(ajaxRequest.readyState == 4){ 
		// (Complete) Get the data from the server's response
              //  document.prereg.email.value = ajaxRequest.responseText;
                var result = ajaxRequest.responseText;
                var n=result.slice(-1);
                if (n == '1') {
                    var msg = '';
                    document.getElementById("email").innerHTML = msg;
                } else {
                    var msg = 'Email address already registered please use another address';
                    document.getElementById("username").focus();
                    document.getElementById("email").innerHTML = msg;
                }
                
                    //ajaxRequest.responseText;
            }
        }
        // Send the Request to the server
        var email = document.prereg.username.value;
        ajaxRequest.open("GET", "checkemail?email="+email  , true);
        ajaxRequest.send();
}

function checkprivacy() {
    if (this.prereg.acceptprivacy.checked && this.prereg.accepttandc.checked ){
        document.getElementById("next").disabled = false;
    } else {  
        var msg = 'you need to acceot the terms and conditions as well as the privacy clause to proceed';
        document.getElementById("privacy").innerHTML = msg;
        document.getElementById("next").disabled = true;
    }
}
//-->
</script>    
<?php
echo '<div id="contentfull">';
echo '<div id="forms">';
//print_r($roles);
//$name = $data[0]['Name'];
//$username = $data[0]['username'];
//echo validation_errors('<div class="error">', '</div>'); 
//$attributes = array('class' => 'frmedit', 'width' => '600px', 'margin' => '0 auto');
//$hidden = array('id' => $uid);
echo '<a href="'.$baseurl.'"><img class="btnimg" src="'.$baseurl.'public/images/close.png" align="right" alt="close" title="Close" border="0" /></a>';

?>
            <p>
                Owners of properties, service providers and advertisers can register as well as tenants of the area. 
                The registration process is a two step process. This is necessary to protect the residents as this site
                is primarily for the use of the residents.
            <ul>
                <li>We verify your email address</li>
                <li>We verify that you are a resident / tenant of the area</li>
                <li>if you are a Service provider / advertiser we will verify your credentials</li>
            </ul>
                Once the verification checks have been done and you have agreed 
                to the terms and conditions you will be sent a temporary password 
                that you can change the first time you log in.
                Alternatively you can register as an advertiser and place adverts <br>
                <strong>Your IP Address is tracked as <?php echo $data['IPaddress']; ?></strong>
            </p>
<?php
       $attributes = array('class' => 'reg', 'id' => 'prereg', 'name' => 'prereg');
       $hidden = array('IPaddress' => $data['IPaddress']);
       echo form_open($baseurl.'index.php/reginfo',$attributes, $hidden);
       echo form_fieldset('<h3>   REGISTER (Step 1) </h3>');
?>       
<table>
    <tr>  <!-- Email  -->
        <td> <?php echo form_label('Email *', 'username'); 
            $usernamec = array('name' => 'username', 
            'id' => 'username',  
            'maxlength'   => '100',
            'value' => $data['username'],    
            'style'       => 'width: 250px' );
            
            $opt = 'onblur="checkemail();"'; ?> </td> 
        <td> <?php echo form_input($usernamec, '', $opt); echo '<br>'.form_error('username'); 
        echo '<em id="email" name="email" ></em>';  ?> </td>
        <td>Please enter a valid Email address as this is required as your username for login purposes </td>
        
    </tr>
    <tr>  <!-- Name -->
        <td width="150px" >
<?php   echo form_label('Name *', 'Name'); 
        //echo form_error('Name'); 
        $namec = array('name' => 'Name', 
               'id' => 'Name',  
               'maxlength'   => '100',
               'value' => $data['Name'],
              'style'       => 'width: 250px' ); ?>  </td>
        <td width="300px" ><?php echo form_input($namec); echo '<br>'.form_error('Name');?>       </td>
        <td width="400px" >This is your full name</td>
        
    </tr>
    
   
       
    <tr>  <!-- Type of Tenant -->
        <td> <?php echo form_label('Registration Type', 'regtypetype');  $level = array('name' => 'regtypetype', 'id' => 'regtypetype' );
        
        // This code allows for all areas to be displayed and the ones that are linked to be selected
        $options = array(
            '0' => '=== Select ===',
            'Property Owner living on the property' => 'Property Owner living on the property',
            'Property Owner not living on the property' => 'Property Owner not living on the property',  
            'Renting the property' => 'Renting the property',
            'Renting portion of property' => 'Renting portion of property',
            'As an Advertiser' => 'As an Advertiser',
            'As a Service Provider' => 'As a Service Provider',
            'Other - living on the property' => 'Other - living on the property',
            );
        $selected = $data['regtypetype'];
?> 
        </td>
        <td> <?php echo form_dropdown('regtypetype', $options); echo '<br>'.form_error('regtypetype');  ?> </td>
        <td> Please select the your interest in the property </td>
    </tr>
     
    <tr>
        <td > <?php echo form_label('I agree to the terms and conditions', 'accepttandc');  $accepttandcc = array('name' => 'accepttandc', 
               'id' => 'accepttandc',  
               'maxlength'   => '1',
              'size'        => '10',
              'checked'     => $data['accepttandc'] );
         $attrib = "onclick='checkprivacy()'";
        echo '<br>';
        ?> 
        </td>
    
        <td> 
            <?php echo form_checkbox($accepttandcc,'','' ,$attrib); echo '<br>'.form_error('accepttandc');  ?>
        </td>
    </tr>
    <tr>
        <td>
            <?php echo form_label('I have read and accept the privacy policy', 'acceptprivacy');  $acceptprivacyc = array('name' => 'acceptprivacy', 
               'id' => 'acceptprivacy',  
               'maxlength'   => '1',
              'size'        => '10',
              'checked'     => $data['acceptprivacy'] ); $attrib = "onclick='checkprivacy()'"; ?>
        </td>
        <td>      
      <?php  echo form_checkbox($acceptprivacyc,'','',$attrib ); echo '<br>'.form_error('acceptprivacy');   ?> 
        </td>
    </tr>
    <tr>
        <td colspan="2" >
            <em id="privacy" name="privacy" ></em>
        </td>
    </tr>
    <tr>
        <!-- This is the Buttons -->
         <td colspan="2" align="right" > <?php 
         $attrib = ' id="next" disabled="true"';
         echo form_submit('next', 'Next', $attrib); ?> 
         </td>    
    </tr>
</table>    
<?=form_fieldset_close()?>
<?=form_close();?>

</div> <!--content-->
</div> <!--login-->

